#include <xp/sys/dll.h>
#include <xp/bas/stdio.h>

int xp_main ()
{
	xp_dll_t dll;
	int (*sum) (int a, int b);

	if (xp_dll_open(&dll, XP_TEXT("./mylib.so")) == XP_NULL) {
		xp_fprintf (xp_stderr, XP_TEXT("cannot open library\n"));
		return -1;
	}

	sum = xp_dll_lookup(&dll, XP_TEXT("sum"));
	if (sum == XP_NULL) {
		xp_fprintf (xp_stderr, XP_TEXT("cannot find symbol\n"));
		xp_dll_close (&dll);
		return -1;
	}

	xp_printf (XP_TEXT("sum = %d\n"), sum (30, 40));
	xp_dll_close (&dll);

	return 0;
}


